import request from "./request"

//查看购物车
export const showshoppingcart = () => {
  return request({
    method: 'get',
    url: 'mall/cart/cart',
    headers: {
      token: `${localStorage.getItem('token')}`
    }
  })
}
//购物车加减
export const addorreduceproduct = (params) => {
  return request({
    method: 'post',
    url: 'mall/cartitem/addorreduce',
    headers: {
      token: `${localStorage.getItem('token')}`
    },
    params: params,
    dataType: "json"
  })
}
//删除商品
export const Batchdeleteproduct = (params) => {
  return request({
    method: 'post',
    url: 'mall/cartitem/select/delete',
    params: params,
    headers: {
      token: `${localStorage.getItem('token')}`
    },
    dataType: "json",
  })
}
// 查询商品信息
export const getproductInfo = (id) => {
  return request({
    method: 'get',
    url: 'mall/product/getProductInfo',
    params: {
      id
    }
  })
}
// 创建订单
export const createorder = (data) => {
  return request({
    method: 'post',
    url: 'mall/orders/createOrders',
    data,
    dataType: "json",
    headers: {
      token: `${localStorage.getItem('token')}`
    }
  })
}

//查看订单
export const listorders = () => {
  return request({
    method: 'get',
    url: 'mall/orders/listOrders',
    headers: {
      token: `${localStorage.getItem('token')}`
    }
  })
}

//支付
export const pay = (data) => {
  return request({
    method: 'post',
    url: 'mall/orders/pay',
    data,
    dataType: "json",
    headers: {
      token: `${localStorage.getItem('token')}`
    }
  })
}